import request from '/@/utils/request';
enum Api {
    AddProjectQa = '/api/projectQa/add',
    DeleteProjectQa = '/api/projectQa/delete',
    BatchDeleteProjectQa = '/api/projectQa/batchDelete',
    UpdateProjectQa = '/api/projectQa/update',
    GetProjectQaByCode = '/api/projectQa/getProjectByCode',
    ImportProjectQa = '/api/projectQa/import',
    DownLoadProjectQa = '/api/ProjectQa/DownLoad',
    PageProjectQa = '/api/projectQa/page',
    MapListByProjectNo = 'api/projectQa/getProjectWJByCode',
    UpdateProjectMap = '/api/Project/updateMap/{projectId}/{projectMapDetailId}'
}

/**
 * 更新项目地图信息
 * @param projectId 项目 ID (integer 类型)
 * @param projectMapDetailId 项目地图详情 ID (string 类型)
 * @param url 可选的 URL 参数 (string 类型)
 */
export const updateProjectMap = ( projectMapDetailId: any, url?: string) => {
    // 构造 URL，替换路径参数
    let urlPath = Api.UpdateProjectMap
        .replace('{projectId}', encodeURIComponent(projectMapDetailId))
        // .replace('{projectMapDetailId}', encodeURIComponent(projectMapDetailId));

    // 构造查询参数
    const params: any = {};
    if (url) {
        params.url = url;
    }

    return request({
        url: urlPath,
        method: 'get',
        params: params, // 添加查询参数
    });
};
// 导入
export const importProjectQa = (params?: any) => {
    const formData = new FormData();
    formData.append('file', params);
    // 请求配置
    const config = {
        headers: {
        },
    };
    request({
        url: Api.ImportProjectQa,
        method: 'post',
        headers:{'Content-Type' : 'multipart/form-data'},
        data: formData,
        // data:formData
    });
}
// 增加wenjuan
export const addProjectQa = (params?: any) =>
    request({
        url: Api.AddProjectQa,
        method: 'post',
        data: params,
    });

// 删除wenjuan
export const deleteProjectQa = (params?: any) =>
    request({
        url: Api.DeleteProjectQa,
        method: 'post',
        data: params,
    });
// 批量删除wenjuan
export const batchDeleteProjectQa = (params?: any) =>
    request({
        url: Api.BatchDeleteProjectQa,
        method: 'post',
        data: params,
    });

// 编辑wenjuan
export const updateProjectQa = (params?: any) =>
    request({
        url: Api.UpdateProjectQa,
        method: 'post',
        data: params,
    });
// 根据项目获取地图信息
export const getMapListByNo = (params?: any) =>
    request({
        url: Api.MapListByProjectNo,
        method: 'post',
        data: params,
    });

// 分页查询wenjuan
export const pageProjectQa = (params?: any) =>
    request({
        url: Api.PageProjectQa,
        method: 'post',
        data: params,
    });
//下载wenjuan模板
export const downLoadProjectQa = (params?: any) =>
    request({
        url: Api.DownLoadProjectQa,
        method: 'post',
        data: params,
        responseType: 'blob',
    });

